import { App, defineAsyncComponent, AsyncComponentLoader } from 'vue'

export default {
  install(app: App) {
    const components = import.meta.glob('./components/*.vue')

    Object.entries(components).forEach(([path, component]) => {
      const name = path.split('/')[2].replace(/\.vue$/, '')
      app.component(
        name,
        defineAsyncComponent(component as AsyncComponentLoader)
      )

      console.log('name', name, 'component', component)
    })
  }
}
